﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
/// <summary>
/// Summary description for Theloaiphim
/// </summary>
public class Theloaiphim
{
	public Theloaiphim()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    DataConnection data = new DataConnection();
    public DataTable TLPhim()
    {
        string sql = "select * from LoaiPhim";
        return data.GetData(sql);
    }
    public DataTable TimTLP(string ten)
    {
      
        SqlParameter p1 = new SqlParameter("@ten",ten);
        string sql = "select * from LoaiPhim where TenTL like '%'+@ten+'%'";
        //TenTL like '%'+@TenTL+'%'
        //if (ten != null)
        //    sql = sql + " and TenTL like '%'+@Ten+'%'";
        return data.GetData(sql, p1);
    }
    public DataTable SuaTLP(int  ma, string ten)
    {
        SqlParameter sp1 = new SqlParameter("@ma", ma);
        SqlParameter sp2 = new SqlParameter("@ten", ten);
        string sql = "update LoaiPhim set TenTL=@ten where MaTL=@ma";
        return data.GetData(sql, sp1, sp2);
    }
    public DataTable XoaTLP(int ma)
    {
        SqlParameter sp1 = new SqlParameter("@MaTL", ma);

        string sql = "Delete from LoaiPhim where Loaiphim.MaTL=@MaTL";
        //string sql = "delete TheLoai where MaTL='"+ma+"'";
        return data.GetData(sql, sp1);
    }
    public DataTable ThemTLP( string ten)
    {
        
        SqlParameter sp2 = new SqlParameter("@ten", ten);
        string sql = "insert into LoaiPhim values(@ten)";
        return data.GetData(sql,  sp2);
    }
}
